<?php

class Validator_Client extends Validator_Default {
    public function isValid($client) {
        $id = explode('.', $client->id);
        if (sizeof($id) != 3) {
            $this->error = CLIENT_ERROR_ID;
            return false;
        }
        if ($id [0] != SERVICE_NO_ID) {
            $this->error = CLIENT_ERROR_NO_ID;
            return false;
        }
        if (!in_array($id [1], explode(',', SERVICE_ALLOWED_AREAS))) {
            $this->error = CLIENT_ERROR_AREA_ID;
            return false;
        }
        if (!intval($id [2])) {
            $this->error = CLIENT_ERROR_FACILITY_ID;
            return false;
        }
        return true;
    }
}
